package pt.ipp.estgf.meteorologia;

import java.util.ArrayList;

import pt.ipp.estgf.cmuweatherlib.*;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class listaDistritos extends ArrayAdapter<Place>{
	ArrayList<Place> mList;
	Context context;
	WeatherCondition currentWCList;

	public listaDistritos(Context context, ArrayList<Place> mList, WeatherCondition currentWCList) {
		super(context,R.layout.listview_distritos, mList);
		this.context = context;
		this.mList = mList;
		this.currentWCList = currentWCList;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		View v = convertView;
		if(v == null){
			LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.listview_distritos, null);
		}
		TextView txtName = (TextView) v.findViewById(R.id.distrito);
		ImageView icon = (ImageView) v.findViewById(R.id.icon);
		
		Place value= mList.get(position);
		txtName.setText(value.getName());
		//Drawable d = Drawable.createFromPath(currentWCList.getIcon());
		icon.setImageResource(R.drawable.s20x20wsymbol_0001_sunny);
		return v;
	}
	
}
